from sqlalchemy.ext.asyncio import AsyncSession

from poker_bot.database import repositories as repo
from poker_bot.database.uow.base import SQLAlchemyBaseUoW


class SQLAlchemyUoW(SQLAlchemyBaseUoW):
    def __init__(
        self,
        *,
        session: AsyncSession,
        user_repo: repo.UserRepoImpl,
        user_reader: repo.UserReaderImpl,
        account_repo: repo.AccountRepoImpl,
        account_reader: repo.AccountReaderImpl,
        withdraw_repo: repo.WithdrawRepoImpl,
        withdraw_reader: repo.WithdrawReaderImpl,
        deposit_repo: repo.DepositRepoImpl,
        deposit_reader: repo.DepositReaderImpl,
        payment_method_reader: repo.PaymentMethodReaderImpl,
        review_reader: repo.ReviewReaderImpl,
        discount_reader: repo.DiscountReaderImpl,
    ) -> None:
        self.user_repo = user_repo
        self.user_reader = user_reader
        self.account_repo = account_repo
        self.account_reader = account_reader
        self.withdraw_repo = withdraw_repo
        self.withdraw_reader = withdraw_reader
        self.deposit_repo = deposit_repo
        self.deposit_reader = deposit_reader
        self.payment_method_reader = payment_method_reader
        self.review_reader = review_reader
        self.discount_reader = discount_reader

        super().__init__(session=session)


def build_uow(session: AsyncSession):
    return SQLAlchemyUoW(
        session=session,
        user_repo=repo.UserRepoImpl(session),
        user_reader=repo.UserReaderImpl(session),
        account_repo=repo.AccountRepoImpl(session),
        account_reader=repo.AccountReaderImpl(session),
        withdraw_repo=repo.WithdrawRepoImpl(session),
        withdraw_reader=repo.WithdrawReaderImpl(session),
        deposit_repo=repo.DepositRepoImpl(session),
        deposit_reader=repo.DepositReaderImpl(session),
        payment_method_reader=repo.PaymentMethodReaderImpl(session),
        review_reader=repo.ReviewReaderImpl(session),
        discount_reader=repo.DiscountReaderImpl(session),
    )
